import com.hxh.demo.StudentController;
import com.hxh.model.Student;
import com.hxh.service.IService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/6/22 21:36
 */
public class App {

    public static void main01(String[] args) {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        IService iService = context.getBean("iServie", IService.class);
        iService.sayHi();
    }

    public static void main02(String[] args) {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        StudentController studentController =
                context.getBean("studentController", StudentController.class);
        studentController.sayHello();
    }

    public static void main(String[] args) {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        Student s1 = context.getBean("s1", Student.class);
        Student s2 = context.getBean("s2", Student.class);
        // 打印 s1 和 s2 信息
        System.out.println(s1);
        System.out.println(s2);
        System.out.println("s1 == s2 ? " + (s1 == s2));
        // 尝试获取 student 不同对象
        Student student02 = context.getBean("student02", Student.class);
        System.out.println(student02);
        System.out.println("s1 == student2 ? " + (s1 == student02));
    }
}
